package com.operate.api.operate.order.service.impl;

import cn.hutool.core.util.DesensitizedUtil;
import com.operate.api.operate.order.dao.OrderRechargeDao;
import com.operate.api.operate.order.domain.po.OrderRechargePO;
import com.operate.api.operate.order.domain.vo.OrderRechargeCountVO;
import com.operate.api.operate.order.domain.vo.OrderRechargeSearchVO;
import com.operate.api.operate.order.domain.vo.OrderRechargeVO;
import com.operate.api.operate.order.service.IOrderRechargeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.math.BigDecimal;
import java.util.List;


@Service
@Transactional
@Slf4j
public class OrderRechargeServiceImpl implements IOrderRechargeService {

    @Autowired
    private OrderRechargeDao dao;


    @Override
    public List<OrderRechargeVO> getList(OrderRechargeSearchVO searchVO) {
        return dao.getList(searchVO);
    }

    @Override
    public OrderRechargeCountVO countRecharge() {
        OrderRechargeCountVO orderRechargeCountVO=new OrderRechargeCountVO();
        orderRechargeCountVO.setOrderMoney(BigDecimal.ZERO);
        orderRechargeCountVO.setOrderNum(BigDecimal.ZERO.intValue());
        orderRechargeCountVO.setUserNum(BigDecimal.ZERO.intValue());
        Example example=new Example(OrderRechargePO.class);
        example.and().andEqualTo("orderState",2);
        orderRechargeCountVO.setOrderNum(dao.selectCountByExample(example));
        orderRechargeCountVO.setOrderMoney(dao.getTotalMoney());
        orderRechargeCountVO.setUserNum(dao.getUserCount());
        return orderRechargeCountVO;
    }
}